<template>
	<!-- 页面全局配置 -->
	<view class="pageconfig">
		<!--vuetop-->
		<view class="flex1   response  flex flex-wrap justify-start  ">
			<view class="flex2   response  flex flex-wrap justify-start  " @click.capture="toUserInfo"
				style="display: flex;flex-direction: row;align-items: center;">
				<view class="flex3    flex flex-wrap justify-start  ">
					<image v-if="hasLogin&&userInfo.avatar_file&&userInfo.avatar_file.url"
						:src="userInfo.avatar_file.url" style="width: 75px;height: 75px;"></image>
					<image v-else src="../../static/logo.png" style="width: 75px;height: 75px;"></image>
				</view>
				<view class="flex5    flex flex-wrap justify-start  "
					style="flex-direction: column;align-items: flex-start;">
					<!-- <text class="text6 "> Hello，啄木鸟</text> -->
					<text class="text6 "
						v-if="hasLogin">{{userInfo.nickname||userInfo.username||userInfo.mobile}}</text>
					<text class="text6 " v-else>{{'登录'}}</text>
				</view>
			</view>
		</view>
		<view class="flex7   response  flex flex-wrap justify-start  ">
			<view class="flex8   response  flex flex-wrap justify-between  " style="align-items: center;">
				<view class="putong9   " @click="to_user_info()">
					<view class="cu-list menu">
						<view class="cu-item arrow" style="background-color: unset;">
							<view class="content">
								<text class="text-left text-bold  text-black ">党员信息</text>
							</view>
						</view>
					</view>
				</view>
				<view class="putong10   ">
					<view class="cu-list menu">
						<view class="cu-item arrow" style="background-color: unset;">
							<view class="content">
								<text class="text-left text-bold  text-black ">我的记录</text>
							</view>
						</view>
					</view>
				</view>
				<view class="flex11   response  flex flex-wrap justify-start  ">
					<view class="flex12  flex-sub   flex flex-wrap justify-start  " @click="to_dati_log()"
						style="flex-direction: column;align-items: center;">
						<view class=" cuIcon-calendar text-red" style="font-size: 64rpx;"></view>
						<view class=" moneybagfill text-blue" style="font-size: 64rpx;"></view>
						<text class="text-gray "> 答题记录</text>
					</view>
					<view class="flex16  flex-sub   flex flex-wrap justify-start  " @click="to_study_log()"
						style="flex-direction: column;align-items: center;">
						<view class=" cuIcon-sort text-red" style="font-size: 64rpx;"></view>
						<view class=" moneybagfill text-blue" style="font-size: 64rpx;"></view>
						<text class="text-gray "> 学习记录</text>
					</view>
					<view class="flex20  flex-sub   flex flex-wrap justify-start  " @click="to_baoming_log()"
						style="flex-direction: column;align-items: center;">
						<view class=" cuIcon-newsfill text-red" style="font-size: 64rpx;"></view>
						<view class=" presentfill text-red" style="font-size: 64rpx;"></view>
						<text class="text-gray "> 报名记录</text>
					</view>
					<view class="flex24  flex-sub   flex flex-wrap justify-start  " @click="to_meeting_log()"
						style="flex-direction: column;align-items: center;">
						<view class=" cuIcon-timefill text-red" style="font-size: 64rpx;"></view>
						<view class=" presentfill text-red" style="font-size: 64rpx;"></view>
						<text class="text-gray "> 个人会议</text>
					</view>
				</view>
			</view>
		</view>
		<view class="flex28   response  flex flex-wrap justify-start  ">
			<view class="flex29   response  flex flex-wrap justify-between  " style="align-items: center;">
				<view class="flex30   response  flex flex-wrap justify-between  " style="align-items: center;">
					<text class="text31 text-gray "> 其他功能</text>
				</view>
				<view class="flex32   response  flex flex-wrap justify-start  ">
					<view class="flex33  flex-sub   flex flex-wrap justify-start  " @click="to_feed_back"
						style="flex-direction: column;align-items: center;">
						<view class=" cuIcon-communityfill text-red" style="font-size: 64rpx;"></view>
						<view class=" moneybagfill text-blue" style="font-size: 64rpx;"></view>
						<text class="text-gray "> 意见反馈</text>
					</view>
					<view class="flex37  flex-sub   flex flex-wrap justify-start  " @click="about"
						style="flex-direction: column;align-items: center;">
						<view class=" cuIcon-loading2 text-red" style="font-size: 64rpx;"></view>
						<view class=" presentfill text-red" style="font-size: 64rpx;"></view>
						<text class="text-gray "> 关于</text>
					</view>
					<view class="flex37  flex-sub   flex flex-wrap justify-start  " @click="toSettings"
						style="flex-direction: column;align-items: center;">
						<view class=" cuIcon-settings text-red" style="font-size: 64rpx;"></view>
						<view class=" presentfill text-red" style="font-size: 64rpx;"></view>
						<text class="text-gray "> 设置</text>
					</view>
				</view>
			</view>
		</view>

		<!--vuebottom-->
	</view>
</template>

<script>
	import Vue from 'vue'
	const db = uniCloud.database();
	import {
		store,
		mutations
	} from '@/uni_modules/uni-id-pages/common/store.js'
	export default {
		data() {
			return {
				bgpic4: 'https://image.meiye.art/Fha6tqRTIwHtlLW3xuZBJj8ZXSX3?imageMogr2/thumbnail/450x/interlace/1',




			};
		},
		computed: {
			userInfo() {
				return store.userInfo
			},
			hasLogin() {
				return store.hasLogin
			},
			appConfig() {
				return getApp().globalData.config
			}
		},
		onLoad() {
			console.log(this.hasLogin);
			if (!this.hasLogin) {
				uni.navigateTo({
					url: "/uni_modules/uni-id-pages/pages/login/login-withpwd",
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}

		},
		methods: {

			about() {
				uni.showToast({
					title: '1.0.0',
					icon: "none"
				});
			},

			to_feed_back() {

				uni.navigateTo({
					url: "/uni_modules/uni-feedback/pages/opendb-feedback/opendb-feedback"
				})
			},
			to_dati_log() {
				console.log("666");
				uni.navigateTo({
					url: "/pages/dati/log"
				})
			},
			to_study_log() {
				uni.navigateTo({
					url: "/pages/study/study_log"
				})
			},
			to_baoming_log() {
				uni.navigateTo({
					url: "/pages/index/activity_log"
				})
			},
			to_meeting_log() {
				uni.navigateTo({
					url: "/pages/meeting/meeting_v2"
				})
			},
			async to_user_info() {
				uni.showLoading({
					title: '加载中',
					mask: false
				});

				if (!this.hasLogin) {
					uni.navigateTo({
						url: "/uni_modules/uni-id-pages/pages/login/login-withpwd"
					});
					return;
				}

				try {
					const user_info = await uniCloud.getCurrentUserInfo();
					const user_info_db = await uniCloud.database().collection("abu_user_info").where({
						user_id: user_info.uid
					}).get();

					uni.hideLoading();

					if (user_info_db.result.data.length > 0) {
						uni.navigateTo({
							url: '/pages/abu_user_info/edit?id=' + user_info_db.result.data[0]._id
						});
					} else {
						uni.navigateTo({
							url: '/pages/abu_user_info/add'
						});
					}
				} catch (error) {
					console.error("Error:", error);
					uni.hideLoading();
				}
			},
			toSettings() {
				uni.navigateTo({
					url: "/pages/ucenter/settings/settings"
				})
			},
			toUserInfo() {
				uni.navigateTo({
					url: '/uni_modules/uni-id-pages/pages/userinfo/userinfo'
				})
			},

		}
	}
</script>

<style lang="less">
	.pageconfig {
		width: 100%;
		overflow: hidden;
		overflow-y: scroll;
		height: 100vh;
	}



	/**pagedomcss**/


	.flex1 {
		width: 100%;
		background-color: #ffffff;
		position: relative;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}

	.flex2 {
		width: 100%;
		position: relative;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}

	.flex3 {
		position: relative;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}

	.flex5 {
		position: relative;
	}

	.text6 {
		font-size: 40rpx;
		margin-top: 10rpx;
		margin-bottom: 10rpx;
		margin-left: 0rpx;
		margin-right: 0rpx;
	}

	.flex7 {
		width: 100%;
		position: relative;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}

	.flex8 {
		width: 100%;
		background-color: #ffffff;
		position: relative;
		padding-top: 20rpx;
		padding-bottom: 20rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
		border-top-left-radius: 20rpx;
		border-top-right-radius: 20rpx;
		border-bottom-right-radius: 20rpx;
		border-bottom-left-radius: 20rpx;
	}

	.putong9 {
		width: 100%;
		background-color: #ffffff;
	}

	.putong10 {
		width: 100%;
		background-color: #ffffff;
	}

	.flex11 {
		width: 100%;
		position: relative;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}

	.flex12 {
		flex: 1;
		position: relative;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}

	.flex16 {
		flex: 1;
		position: relative;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}

	.flex20 {
		flex: 1;
		position: relative;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}

	.flex24 {
		flex: 1;
		position: relative;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}

	.flex28 {
		width: 100%;
		position: relative;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}

	.flex29 {
		width: 100%;
		background-color: #ffffff;
		position: relative;
		padding-top: 20rpx;
		padding-bottom: 20rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
		border-top-left-radius: 20rpx;
		border-top-right-radius: 20rpx;
		border-bottom-right-radius: 20rpx;
		border-bottom-left-radius: 20rpx;
	}

	.flex30 {
		width: 100%;
		position: relative;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}

	.text31 {
		font-size: 36rpx;
	}

	.flex32 {
		width: 100%;
		position: relative;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}

	.flex33 {
		flex: 1;
		position: relative;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}

	.flex37 {
		flex: 1;
		position: relative;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}
</style>